home *** CD-ROM | disk | FTP | other *** search
-
- MSGRCV(2) UNIX Programmer's Manual MSGRCV(2)
-
- NNAAMMEE
- mmssggrrccvv - receive a message from a message queue
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
- ##iinncclluuddee <<ssyyss//iippcc..hh>>
- ##iinncclluuddee <<ssyyss//mmssgg..hh>>
-
- _i_n_t
- mmssggrrccvv(_i_n_t _m_s_q_i_d, _v_o_i_d _*_m_s_g_p, _s_i_z_e___t _m_s_g_s_z, _l_o_n_g _m_s_g_t_y_p, _i_n_t _m_s_g_f_l_g)
-
- DDEESSCCRRIIPPTTIIOONN
- The mmssggrrccvv() function receives a message from the message queue specified
- in _m_s_q_i_d, and places it into the structure pointed to by _m_s_g_p. This
- structure should consist of the following members:
-
- long mtype; /* message type */
- char mtext[1]; /* body of message */
-
- _m_t_y_p_e is an integer greater than 0 that can be used for selecting mes-
- sages, _m_t_e_x_t is an array of bytes, with a size up to that of the system
- limit (MSGMAX).
-
- The value of _m_s_g_t_y_p has one of the following meanings:
-
- ++oo _m_s_g_t_y_p is greater than 0. The first message of type _m_s_g_t_y_p will be
- received.
-
- ++oo _m_s_g_t_y_p is equal to 0. The first message on the queue will be re-
- ceived.
-
- ++oo _m_s_g_t_y_p is less than 0. The first message of the lowest message type
- that is less than or equal to the absolute value of _m_s_g_t_y_p will be
- received.
-
- _m_s_g_s_z specifies the maximum length of the requested message. If the re-
- ceived message has a length greater than _m_s_g_s_z it will be silently trun-
- cated if the MSG_NOERROR flag is set in _m_s_g_f_l_g, otherwise an error will
- be returned.
-
- If no matching message is present on the message queue specified by
- _m_s_q_i_d, the behaviour of mmssggrrccvv() depends on whether the IPC_NOWAIT flag
- is set in _m_s_g_f_l_g or not. If IPC_NOWAIT is set, mmssggrrccvv() will immediately
- return a value of -1, and set _e_r_r_n_o to EAGAIN. If IPC_NOWAIT is not set,
- the calling process will be blocked until:
-
- ++oo A message of the requested type becomes available on the message
- queue.
-
- ++oo The message queue is removed, in which case -1 will be returned, and
- _e_r_r_n_o set to EINVAL.
-
- ++oo A signal is received and caught. -1 is returned, and _e_r_r_n_o set to
- EINTR.
-
- If a message is successfully received, the data structure associated with
- _m_s_q_i_d is updated as follows:
-
- ++oo _m_s_g___c_b_y_t_e_s is decremented by the size of the message.
-
-
-
- ++oo _m_s_g___l_r_p_i_d is set to the pid of the caller.
-
- ++oo _m_s_g___l_r_t_i_m_e is set to the current time.
-
- ++oo _m_s_g___q_n_u_m is decremented by 1.
-
- RREETTUURRNN VVAALLUUEESS
- Upon successful completion, mmssggrrccvv() returns the number of bytes received
- into the _m_t_e_x_t field of the structure pointed to by _m_s_g_p. Otherwise, -1
- is returned, and _e_r_r_n_o set to indicate the error.
-
- EERRRROORRSS
- mmssggrrccvv() will fail if:
-
- [EINVAL] _m_s_q_i_d is not a valid message queue identifier
-
- The message queue was removed while mmssggrrccvv() was waiting
- for a message of the requested type to become available on
- it.
-
- _m_s_g_s_z is less than 0.
-
- [E2BIG] A matching message was received, but its size was greater
- than _m_s_g_s_z and the MSG_NOERROR flag was not set in _m_s_g_f_l_g.
-
- [EACCESS] The calling process does not have read access to the mes-
- sage queue.
-
- [EFAULT] _m_s_g_p points to an invalid address.
-
- [EINTR] The system call was interrupted by the delivery of a sig-
- nal.
-
- [EAGAIN] There is no message of the requested type available on the
- message queue, and IPC_NOWAIT is set in _m_s_g_f_l_g.
-
- SSEEEE AALLSSOO
- msgsnd(2), msgctl(2), msgget(2)
-
- BBUUGGSS
- NetBSD does not define the EIDRM error value, which should be used in the
- case of a removed message queue, nor the ENOMSG value, which should be
- used when no suitable message is available and IPC_NOWAIT is set.
-
- HHIISSTTOORRYY
- Message queues appeared in the first release of AT&T Unix System V.
-
- NetBSD August 17, 1995 2
-